<!-- 查询 content -->
{{ $contentSQL := "* FROM content WHERE id=? and status<3 order by status desc, sortNo desc" }}

{{ if eq .userType 1}}
  {{ $contentSQL ="* FROM content WHERE id=? order by sortNo desc" }}
{{end}}

{{ $content := selectOne "content" $contentSQL .UrlPathParam }}

{{ $prevContent := selectOne "content"  "id,title FROM content WHERE status in (1,2) and sortNo < ? order by sortNo desc " $content.SortNo  }}
{{ $nextContent := selectOne "content"  "id,title FROM content WHERE status in (1,2) and sortNo > ? order by sortNo asc " $content.SortNo  }}

<!DOCTYPE html>
<html>
<head>
  <title>{{ $content.Title }}</title>
  <meta name="description" content="{{ $content.Description }}" />
  <meta name="keyword" content="{{ $content.Keyword }}" />
  <style>
    .markdown p img{
      display: block;
      margin: auto;
    }
  </style>
  {{template "bodystart.html" $content }}

      <header class="book-header">
        <div class="flex align-center justify-between">
          <label for="menu-control">
            <img src="{{basePath}}image/menu.svg" class="book-icon" alt="Menu" />
          </label>
          <strong>{{ $content.Title }}</strong>
          <label for="toc-control">
            <img src="{{basePath}}image/toc.svg" class="book-icon" alt="Table of Contents" />
          </label>
        </div>
        <aside class="hidden clearfix">
          <nav id="TableOfContents">
            <ul>
              <li>
                {{safeHTML $content.Toc }}
              </li>
            </ul>
          </nav>
        </aside>
      </header>

      <article class="markdown">
         {{ safeHTML $content.Content }}
       </article>

      <footer class="book-footer">
        <div class="flex flex-wrap justify-between">
          {{if $prevContent.Id }}
          <div><a class="flex align-center" href="{{basePath}}{{ trimPrefixSlash $prevContent.Id }}" title="{{$prevContent.Title}}"><span>< {{$prevContent.Title}}</span></a></div>
          {{else}}
          <div><a class="flex align-center"><span>  </span></a></div>
          {{end}}
          {{if $nextContent.Id }}
          <div><a class="flex align-center" href="{{basePath}}{{ trimPrefixSlash $nextContent.Id }}" title="{{$nextContent.Title}}"><span>{{$nextContent.Title}} ></span></a></div>
          {{else}}
          <div><a class="flex align-center"><span>  </span></a></div>
          {{end}}
        </div>
        <script>
          (function(){function a(c){const a=window.getSelection(),b=document.createRange();b.selectNodeContents(c),a.removeAllRanges(),a.addRange(b)}document.querySelectorAll("pre code").forEach(b=>{b.addEventListener("click",function(c){if(window.getSelection().toString())return;a(b.parentElement),navigator.clipboard&&navigator.clipboard.writeText(b.parentElement.textContent)})})})()
        </script>
      </footer>
      <div class="book-comments"></div>
      <label for="menu-control" class="hidden book-menu-overlay"></label>
      
{{template "bodyend.html" $content }}

<style>
  .markdown pre {
    background:#ECEFF3;
  }
</style>